package lanou3g.myfirstapp36kr.myvolleysingleton;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

/**
 * Created by dllo on 16/8/15.
 */
public class DaoMasterSingleton {
    private static Context context;
    private DaoMaster daoMaster;
    private SQLiteDatabase db;
    private DaoSession daoSession;
    private ColectionDao colectionDao;
    private static DaoMasterSingleton daoMasterSingleton = new DaoMasterSingleton();
    public static DaoMasterSingleton getDaoMasterSingleton(){
        return daoMasterSingleton;
    }
    private DaoMasterSingleton(){
        context = My.getContext();
        new Thread(new Runnable() {
            @Override
            public void run() {

                DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(context, "my36kr.db");
                db = devOpenHelper.getWritableDatabase();
                daoMaster = new DaoMaster(db);
                daoSession = daoMaster.newSession();
                colectionDao = daoSession.getColectionDao();
            }
        }).start();
    }
    public ColectionDao getColectionDao(){

        return colectionDao;
    }

}
